package com.wy;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @描述
 * @创建人 wangyue
 * @创建时间2020/12/1714:26
 */
@SpringBootApplication
@EnableEurekaClient
public class RoleApplication {

    public static void main(String[] args) {
        SpringApplication.run(RoleApplication.class,args);
    }

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
    @Bean
    public IRule ribbonRule(){
        return new RandomRule();//实例化与配置文件相对应的策略类
    }

}
